using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Billing2
{
    public class NewChangeRequest : Page
    {
        protected Button btn_create;
        protected Button btn_update;
        protected Button btn_delete;
        protected Button btn_terminate;
        protected Button btn_cct;
        protected Button btn_batch_create;
        //protected Button btn_batch_update;
        //protected Button btn_batch_delete;
        protected Button btn_batch_terminate;
        //protected Button btn_batch_cct;

        protected HiddenField xChangeRequestType;
        protected HiddenField xChangeRequestStatus;
        protected HiddenField xChangeRequestID;

        public string ChangeRequestType
        {
            get
            {
                return this.xChangeRequestType.Value;
            }
        }

        public string ChangeRequestStatus
        {
            get
            {
                return this.xChangeRequestStatus.Value;
            }
        }

        public string ChangeRequestID
        {
            get
            {
                return this.xChangeRequestID.Value;
            }
        }

        public bool Read0
        {
            get
            {
                return Convert.ToBoolean(this.ViewState["xRead0"]);
            }
            set
            {
                this.ViewState["xRead0"] = value;
            }
        }

        public bool Create0
        {
            get
            {
                return Convert.ToBoolean(this.ViewState["xCreate0"]);
            }
            set
            {
                this.ViewState["xCreate0"] = value;

                this.btn_create.Visible = value;
                this.btn_update.Visible = value;
                this.btn_delete.Visible = value;
                this.btn_terminate.Visible = value;
                this.btn_cct.Visible = true;

                this.btn_batch_create.Visible = value;
                //this.btn_batch_update.Visible = value;
                //this.btn_batch_delete.Visible = value;
                this.btn_batch_terminate.Visible = value;
                //this.btn_batch_cct.Visible = true;
            }
        }

        public bool Update0
        {
            get
            {
                return Convert.ToBoolean(this.ViewState["xUpdate0"]);
            }
            set
            {
                this.ViewState["xUpdate0"] = value;
            }
        }

        public bool Delete0
        {
            get
            {
                return Convert.ToBoolean(this.ViewState["xDelete0"]);
            }
            set
            {
                this.ViewState["xDelete0"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Session["SiteID"] == null)
                this.Response.Redirect("default.aspx",true);
            //if (this.Page.IsPostBack)
            //    return;
            this.GetPermission();
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ViewStateUserKey = Session.SessionID;
        }

        protected void btnCompose_Click(object sender, EventArgs e)
        {
            this.xChangeRequestType.Value = Microsoft.Security.Application.Encoder.HtmlEncode(((Button)sender).CommandName.ToLower());
            this.xChangeRequestID.Value = Common.EncryptData("0");
            this.xChangeRequestStatus.Value = "0";
        }

        private void GetPermission()
        {
            ClsACLHelper clsAclHelper = new ClsACLHelper();
            string pageName = this.Page.ToString().Substring(4, this.Page.ToString().Substring(4).Length - 5) + ".aspx";
            clsAclHelper.SetPermission(LoginUser.TreeMenu, pageName);
            this.Create0 = clsAclHelper.Create0;
            this.Delete0 = clsAclHelper.Delete0;
            this.Read0 = clsAclHelper.Read0;
            this.Update0 = clsAclHelper.Update0;
            if (clsAclHelper.Read0)
                return;
            this.Response.Redirect("logout.aspx",true);
        }

        protected void btn_batch_Click(object sender, EventArgs e)
        {
            this.xChangeRequestType.Value = ((Button)sender).CommandName.ToLower();
            this.xChangeRequestID.Value = Common.EncryptData("0");
            this.xChangeRequestStatus.Value = "0";
        }

       
    }
}
